//
//  AppTools.h
//  WIFI
//
//  Created by macbook on 2022/4/18.
//

#import <Foundation/Foundation.h>
#import <ContactsUI/ContactsUI.h>
#import <sys/utsname.h>

NS_ASSUME_NONNULL_BEGIN

typedef void(^SuccessBlock)(id responseObject);

@interface AppTools : NSObject<CNContactPickerDelegate>

/**
 将字符串转成NSDate类型
 */
+ (NSDate *)dateFromString:(NSString *)dateString;

/**
 判断对象是否为空
 */
+ (BOOL)isEmpty:(id)object;

/**
 MD5加密
 */
+ (NSString *)md5:(NSString *)string;

/**
 获取当前显示的视图控制器
 */
+ (UIViewController *)getCurrentVC;

/**
 获取window
 */
+ (UIWindow *)getWindow;

/**
 获取当前时间 YYYY-MM-dd HH:mm:ss
 */
+ (NSString*)getCurrentTimes;

/**
 获取当前时间 自定义格式
 */
+ (NSString*)getCurrentTimesType:(NSString *)timeType;

/**
 传入今天的时间，返回明天的时间
 */
+ (NSString *)GetTomorrowDay:(NSDate *)aDate;


/**
 时间戳毫秒转日期
 */
+ (NSString *)UTCchangeDate:(NSString *)utc format:(NSString *)format;

/**
 日期转时间戳
 */
+ (NSString *)TimeToTimestampWtihString:(NSString *)time;

/**
 日期转时间戳 自定义格式
 */
+ (NSString *)TimeToTimestampWtihString:(NSString *)time format:(NSString *)format;

/**
 判断某个时间是否处于当天内
 */
+ (BOOL)validateWithDate:(NSDate *)date;

/**
 获取当前时间戳
 */
+ (NSString *)getNowTimeTimestamp;

/**
 切割UIView左上角为圆角
 */
+ (CAShapeLayer *)clipTopLeftByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 切割UIView右上角为圆角
 */
+ (CAShapeLayer *)clipTopRightByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 切割UIView左边两个角为圆角
 */
+ (CAShapeLayer *)clipAllCornersByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 切割UIView左边两个角为圆角
 */
+ (CAShapeLayer *)clipTopLeftAndLeftByRoundingCorners:(UIView *)view radii:(CGSize)size;
/**
 切割UIView右边两个角为圆角
 */
+ (CAShapeLayer *)clipTopRightAndRightByRoundingCorners:(UIView *)view radii:(CGSize)size;
/**
 切割UIView上面两个角为圆角
 */
+ (CAShapeLayer *)clipTopRightAndLeftByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 切割UIView全部角为圆角
 */
+ (CAShapeLayer *)clipAllRoundingCorners:(UIView *)view radii:(CGSize)size;


/**
 切割UIView下面两个角为圆角
 */
+ (CAShapeLayer *)clipBottomRightAndLeftByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 切割UIView右下角为圆角
 */
+ (CAShapeLayer *)clipBottomRightByRoundingCorners:(UIView *)view radii:(CGSize)size;

/**
 json转字典
 */
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;

/**
 字典转json
 */
+ (NSString *)jsonStringWithDictionary:(NSDictionary *)dict;

/**
 数组转json
 */
+ (NSString *)jsonStringWithNSArray:(NSArray *)arr;

/**
 json转数组
 */
+ (NSArray *)arrayWithJsonString:(NSString *)jsonStr;

/**
 改变字符串中某一段字符串的颜色和大小
 */
+ (NSMutableAttributedString *)setAttStringWithString:(NSString *)string changeString:(NSString *)changeString changeColor:(NSString *)changeColor changeFont:(UIFont *)changeFont;

/**
 根据文字和字体大小获取size
 */
+ (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize;

+ (BOOL)isSimuLator;

/**
 获取当前网络状态
-1.未知网络
 0.网络不可达
 1.蜂窝数据
 2.WIFI
 3.无网络
 */
+ (NSInteger)getCurrentNetworkStatus;

/*
 即时获取当前网络状态
-1.未知网络
 0.网络不可达
 1.蜂窝数据
 2.WIFI
 3.无网络
 */
+ (NSInteger)reachabilityCurrentNetworkStatus;

/**
 获取当前时间的: 前一周(day:-7)丶前一个月(month:-30)丶前一年(year:-1)的时间戳
 */
+ (NSString *)getExpectTimestamp:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day;

/*
 渐变色
 */
+ (void)createByCAGradientLayer:(UIColor *)startColor endColor:(UIColor *)endColor layerFrame:(CGRect)frame;

/*
 获取设备名
 */
+ (NSString *)getDeviceName;

/*
 保存IDFA
 */
+ (void)saveIDFA:(NSString *)idfa;

/*
 读取IDFA
 */
+ (NSString *)getIDFA;

// 获取或创建IDFV
+ (NSString *)getOrCreatePseudoIDFV;

/*
 获取登录token
 */
+ (NSString *)getLoginToken;

/*
 获取登录国家
 */
+ (NSString *)getLoginCountry;

/*
 是否是首次启动
 */
+ (BOOL)isFirstOpen;

/*
 是否登录
 */
+ (BOOL)isLogin;

/*
 跳转到登录
 */
+ (void)toLogin;

@end

NS_ASSUME_NONNULL_END
